When i generate a document with custom papersize (size like A0) and insert image into the shape on the document, the image results stretched in x and y.
The shape/image size has any restrictions ?
Best regards
When i generate a document with custom papersize (size like A0) and insert image into the shape on the document, the image results stretched in x and y.
The shape/image size has any restrictions ?
Best regards
Hi Michael,
Thanks for your request. There is size restrictions. Could you please provide me a sample code and files that will allow me to reproduce the problem. I will check the issue and provide you more information.
Best regards,
I will send you my sample source wihtout licenze but with my sample image “4.jpg”
also i send you the result … the .doc file and the .pdf file
as you can se … opening the .doc file … words doesn’t interpret the size in a right way
but opening the pdf in acrobat reader the page size is a real A0
the problem is that the image into it … isn’t in his original size but it is scaled.
The image has to be big as the document …
thx
sorry
but the image hasn’t to be big as the document … it isn an A0
but the image is resized in his lenght (x-size) you can se it on the image in the pdf
Hi Michael,
Thank you for additional information. If I understand you correctly, you need to generate PDF where the whole page is occupied by an image. If so, I think, you can try using the same technique as described here:
https://docs.aspose.com/words/net/convert-a-document/
Code in this article is in C#, please let me know if you need assistance in translating it to Java.
Best regards,
I try it on that way …
but the problem is stell there, the image will be stretched in x-lenght
in my opinion the problem is the CUSTOM PAPER SIZE if we use an A3 or A4 paper size it works fine
here my test code and as attachment the result
try
{
License lic = new License();
InputStream inputStream = getClass().getResourceAsStream(“Aspose.Words(Java).lic”);
lic.setLicense(inputStream);
DocumentBuilder builder = null;
Document doc = new Document();
builder = new DocumentBuilder(doc);
PageSetup ps = builder.getPageSetup();
ps.setPaperSize(PaperSize.CUSTOM);
ps.setPageWidth(ConvertUtil.millimeterToPoint(1189));
ps.setPageHeight(ConvertUtil.millimeterToPoint(840));
InputStream inputStreamImage = getClass().getResourceAsStream(“4.jpg”);
builder.insertImage(inputStreamImage, RelativeHorizontalPosition.PAGE, 0, RelativeVerticalPosition.PAGE, 0, ps.getPageWidth(), ps.getPageHeight(), WrapType.NONE);
PdfOptions pdfOptions = new PdfOptions();
if (System.getProperty(“os.name”).equalsIgnoreCase(“Linux”))
{
Properties properties = new Properties();
try
{
properties.load(new FileInputStream(“stampe.properties”));
pdfOptions.setTrueTypeFontsFolder(properties.getProperty(“fonts_dir”));
}
catch (IOException e)
{
pdfOptions.setTrueTypeFontsFolder("/usr/java/fonts");
}
}
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
OutputStream outputStreamDOC = new FileOutputStream("/tmp/a0.doc");
OutputStream outputStreamPDF = new FileOutputStream("/tmp/a0.pdf");
doc.save(outputStreamDOC, SaveFormat.DOC);
doc.saveToPdf(0, doc.getPageCount(), byteArrayOutputStream, pdfOptions);
byteArrayOutputStream.writeTo(outputStreamPDF);
}
catch (IOException e)
{
e.printStackTrace();
}
catch (Exception e)
{
e.printStackTrace();
}
System.out.println(“END”);
Hi Michael,
Thanks for your inquiry.
It seems the issue here is the same one reported in another thread just recently. This distortion is happening because the basis of Aspose.Words is built off processing MS Word documents, and in these types of documents the maximum size of either side of the page is 55.87cm. Your code modifies the page size to be A0 which is much larger than that max . Please note that A0 paper size is not supported in MS Word at all.
This large page size exceeding the maximum causes the output to be corrupt when saving to DOC and appear unexpected when rendering to PDF.
I have linked this behaviour to the appropriate issue, we will inform you when it’s fixed. In the mean time, I can only suggest to use a smaller page size.
Thanks,
Ok thx,
should it works on PDF Kit?
What i need is a plan PDF Page with custom paper size <= A0 and then putting an image into it.
I can use Aspose words to make my other sites with text and MailMerge and than using pdf kit to make the other site with the image and then put the to pages togehter also with pdf kit?
I’m right?
I wish you and all the GREAT TEAM from ASPOSE (your support is FANTASTIC)
happy christmas
best regards
Michael
Hi Michael,
Thanks for this additional information.
Yes that sounds right. If you have any trouble the Pdf.Kit team will glady answer any queries.
Thank you for that kind feedback, we appreciate it. A very Merry Christmas to you too.
Thanks,
Thx
a last question, Should i use PdfKit or Pdf
i read on your page PdfKit is for manipulating existing Pdf Files and Pdf is for creating Pdf Files, so I think I have to use Aspose.PDF
at the moment I’m not able to download anything from your server, there is something not working.
thx
Michael
Hi Michael,
Thanks for your inquiry.
I think you may beable to generate a PDF using Aspose.Words and then add the image on using Aspose.Pdf.Kit. You will need to clarify this is possible and the best method with the Pdf/Pdf.Kit teams.
Regarding the downloads, they appear to be working on my side. Can you try them again and if the issue remains can you provide a link as an example.
Thanks,