I have generated PDF using a MS Word File. The alignment are not coming as same.
It is an Urgent Issue. Please respond as soon as possible.
Attached Word Document and Generated PDF
GeneratedPDF.pdf (96.3 KB)
TestTemplate.docx (75.8 KB)
I have generated PDF using a MS Word File. The alignment are not coming as same.
It is an Urgent Issue. Please respond as soon as possible.
Attached Word Document and Generated PDF
GeneratedPDF.pdf (96.3 KB)
TestTemplate.docx (75.8 KB)
Can you please provide more details about the specific alignment issues you are experiencing with the generated PDF compared to the Word document?
Please share following details and we’ll look into this issue:
import com.groupdocs.conversion.Converter;
import com.groupdocs.conversion.ConverterSettings;
import com.groupdocs.conversion.contracts.ConverterSettingsProvider;
import com.groupdocs.conversion.contracts.documentinfo.IDocumentInfo;
import com.groupdocs.conversion.internal.c.a.w.FolderFontSource;
import com.groupdocs.conversion.internal.c.a.w.FontSourceBase;
import com.groupdocs.conversion.internal.c.a.w.SystemFontSource;
import com.groupdocs.conversion.internal.c.a.w.FontSettings;
import com.groupdocs.conversion.options.convert.PdfConvertOptions;
import com.groupdocs.conversion.options.convert.PdfDocumentInfo;
import com.groupdocs.conversion.options.convert.PdfOptions;
import com.groupdocs.conversion.options.load.WordProcessingLoadOptions;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import static jdk.xml.internal.SecuritySupport.getClassLoader;
public class Main {
public static void main(String[] args) {
System.out.println(“Hi”);
String filePath = “templateGDocs.docx”; // Replace with your file path
String outputFilePath = “output.pdf”;
try {
// Create a File object
File file = new File(filePath);
String userHome = System.getProperty(“user.home”);
String outputFilePathString = userHome + File.separator + “outputfile.docx”;
System.out.println(outputFilePathString);
// Open an InputStream for the file
try (InputStream inputStream = Main.class.getClassLoader().getResourceAsStream(filePath)) {
WordProcessingLoadOptions loadOptions = new WordProcessingLoadOptions();
// Below is required for adding Tags in the output PDF documnet
loadOptions.setPreserveDocumentStructure(true);
try (Converter converter = new Converter(() -> inputStream, () -> loadOptions)) {
try (ByteArrayOutputStream ms = new ByteArrayOutputStream()) {
PdfConvertOptions convertOptions = new PdfConvertOptions();
PdfOptions pdfOptions = convertOptions.getPdfOptions();
pdfOptions.getFormattingOptions().setDisplayDocTitle(true);
PdfDocumentInfo pdfDocumentInfo = pdfOptions.getDocumentInfo();
pdfDocumentInfo.setTitle("Test");
converter.convert(() -> ms, convertOptions);
byte[] outputPdfBytes = ms.toByteArray();
System.out.println("Generated PDF content size in bytes: " + outputPdfBytes.length);
try (FileOutputStream fileOutputStream = new FileOutputStream(outputFilePath)) {
fileOutputStream.write(outputPdfBytes);
System.out.println("File created successfully!");
} catch (IOException e) {
e.printStackTrace();
}
}
} catch (IOException e) {
System.out.println(e.getMessage());
throw e;
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
API Version: GroupDocs.Total for Java → Version 3.0
@akashkrishnan
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): TOTALJAVA-258
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Is there any update on this issue? We have few customers who are waiting on this. Can you please let us know any ETA on the issue?
I see that we have given the API version used by us is Groupdocs total v3.0 but as per my knowledge we use Groupdocs conversion 24.6 JAVA. Can you please make sure this fix is available in next Groupdocs Conversion version
We have tested the bug using GroupDocs.Total for Java versions 25.1 and the pre-release 25.2. Additionally, we conducted tests in a Docker environment. The file layout appears to be correct. Please see the attached files.zip (1.4 MB). We have also included the project for testing, which was conducted using Java versions 8, 17, and 22.
Can you share the zip file in drive as @akashkrishnan is unavailable currently and I am not the owner of this thread, hence unable to download.