|
|
Zoom of a PDF and subsequent placement at certain position
Last post 07-25-2008, 10:57 PM by Felix.Liu. 18 replies.
-
06-25-2008, 9:13 AM |
-
emilioMalaga
-
-
-
Joined on 02-28-2008
-
Sweden
-
Posts 56
-
-
-
-
Issues: PdfKitNet-5409
|
Zoom of a PDF and subsequent placement at certain position
Attachment: Present (inaccessible)
Hi,
Mi company is very close to take to production an application that uses Aspose.Pdf.Kit, but we found an issue, hope you could help us.
I'm trying to zoom a PDF, and place it at a certain position. This is the code I use:
string outputFileName = "ZoomRaw_1.pdf";
// Original PDF: IT HASN'T A4 SIZE FileStream input = File.Open(testFilePath + "ostgota-correspondenten_2008_4_17_1_6_63877.pdf", FileMode.Open);
FileStream output = File.Open(outputFileName , FileMode.Create); // We bind the original PDF to PdfPageEditor object, set the zoom, // and save it to the empty PDF:
PdfPageEditor pdfEditor = new PdfPageEditor();
pdfEditor.BindPdf(input);
/*pdfEditor.Alignment = AlignmentType.Center; pdfEditor.VerticalAlignment = Aspose.Pdf.Kit.VerticalAlignmentType.Bottom;*/
// new position is (0 mm, 0 mm). Its is left-bottom origin, according to Aspose // documentation pdfEditor.MovePosition(0 * ImageRender.MM_to_INCHES, 0 * ImageRender.MM_to_INCHES);
pdfEditor.Zoom = float.Parse("0,3"); // <--------
// final page format is A4 pdfEditor.PageSize = PageSize.A4;
pdfEditor.Save(output); // save to new file
output.Flush(); output.Close();
input.Flush(); input.Close();
The problem is that I have set the position (0 mm, 0 mm) -left bottom origin, according to Aspose documentation- but that is not the result (the final 'y' is higher ), even if I skip the line that sets the page size to A4. I tried to set other origin coordinates, and the result is not exactly placed at them.
Related to this: As you can read above, I left between comments next code lines:
/*pdfEditor.Alignment = AlignmentType.Center;
pdfEditor.VerticalAlignment = Aspose.Pdf.Kit.VerticalAlignmentType.Bottom;*/
If I use them, apply the zoom and convert to A4, the result may cut a piece of the original PDF.
It also seems like if you use the PdfEditor.Alligment properties, the PdfEditor.MovePosition takes no effect
I've been struggling trying many different options, and I still can't find how to combine these three members:
- PdfEditor.Zoom - PdfEditor.MovePosition - and PdfEditor.Alignment, PdfEditor.VerticalAlignment
...in order to obtain A ZOOMED PDF, WHERE THE RESULT IS AT A CERTAIN POSITION, and it doesn't go out the bounds (doesn't get cut). (I'm sure that it is not the final size that send it out of the bounds, but the position)
Regards.
|
|
-
06-25-2008, 3:03 PM |
-
codewarior
-
-
-
Joined on 05-05-2008
-
-
Posts 1,203
-
-
-
-
|
Re: Zoom of a PDF and subsequent placement at certain position
Hello Emilio,
I have tested the code and have been able to generate the issues. I will discuss it with developers and will let you update. Sorry for inconvenience.
Nayyer Shahbaz Support Developer Aspose Changsha Team About Us Contact Us
|
|
-
06-26-2008, 12:59 AM |
-
Felix.Liu
-
-
-
Joined on 10-10-2007
-
-
Posts 300
-
-
-
-
|
Re: Zoom of a PDF and subsequent placement at certain position
Hi,
Sorry for the inconvenience.
Aspose.Pdf.Kit places the real contents to a Pdf document with a default margin of (10 point,50 point). So, please use PdfPageEditor.MovePosion(-10,-50) to move the contents to left-bottom (1 point = 1/72 inch).
And thanks for your help, we'll add the information to our Documentation later.
Best regards,
Felix Liu Developer Aspose Changsha Team About Us Contact Us
|
|
-
06-26-2008, 2:08 AM |
-
emilioMalaga
-
-
-
Joined on 02-28-2008
-
Sweden
-
Posts 56
-
-
-
-
|
Re: Zoom of a PDF and subsequent placement at certain position
Hi,
No worries. I've used that information and I've tried same example with:
PdfEditor.MovePosition(-10/72, -50/72)
... that should be the left bottom corner of the document, or? In that case, what is the reason why the contents result in being placed out of bounds?
I thought that the left-bottom corner of the original PDF contents would be moved, after the Zoom() and the MovePosition(), to this new position. Is that correct?
Regards.
|
|
-
06-26-2008, 9:02 AM |
-
emilioMalaga
-
-
-
Joined on 02-28-2008
-
Sweden
-
Posts 56
-
-
-
-
|
Re: Zoom of a PDF and subsequent placement at certain position
Attachment: Present (inaccessible)
Hi,
I must use points, so I do:
PdfEditor.MovePosition(-10, -50)
... And it doesn't work. For example, use the atatched PDF file ("DALA-07-020-20080505-003.pdf").
Next is the whole code. As you see in "ZoomRaw_1.pdf", the contents are out of bounds after the ZOOM and the MOVE_POSIION. Why the MovePosition() method does not work properly ?
string outputFileName = "ZoomRaw_1.pdf";
// Original PDF FileStream input = File.Open(testFilePath + "DALA-07-020-20080505-003.pdf", FileMode.Open);
FileStream output = File.Open(outputFileName , FileMode.Create); // We bind the original PDF to PdfPageEditor object, set the zoom, // and save it to the empty PDF:
PdfPageEditor pdfEditor = new PdfPageEditor();
pdfEditor.BindPdf(input);
pdfEditor.MovePosition(-10 ,-50); pdfEditor.Zoom = float.Parse("0,8");
pdfEditor.Save(output); // save to new file
output.Flush(); output.Close();
input.Flush(); input.Close();
Regards.
|
|
-
06-26-2008, 9:09 AM |
-
Felix.Liu
-
-
-
Joined on 10-10-2007
-
-
Posts 300
-
-
-
-
|
Re: Zoom of a PDF and subsequent placement at certain position
Hi,
After further researching, I find the conditions and affect factors of the problem are much more complicated than I've explained above. I will discuss it with other developers and hope we could offer you either a clear explanation or more friendly APIs next week :-)
(logged as PdfKitNet-5409)
Thanks,
Felix Liu Developer Aspose Changsha Team About Us Contact Us
|
|
-
06-27-2008, 4:39 AM |
-
emilioMalaga
-
-
-
Joined on 02-28-2008
-
Sweden
-
Posts 56
-
-
-
-
|
Re: Zoom of a PDF and subsequent placement at certain position
Attachment: Present (inaccessible)
Hi,
I'm providing you with more examples that could help to clarify the issue..
Since I cannot use PdfEditor.MovePosition() properly, I've tried so set the position not so specifically with:
PdfEditor.Alignment = AlignmentType.Center; PdfEditor.VerticalAlignment = VerticalAlignmentType.Bottom;
The result works fine sometimes, and sometimes not. So, I wonder if it's an Aspose bug, or some differences in the settings of the original PDF. If that is the case, it would be good to know from you, PDF experts, which are those settings which differ.
See attached zip file, it contains 2 folders: One with successful examples (both original PDF and result after zoom + alligment), and another one with failed examples.
The logic applied was exactly the same (Zoom, set the Alligment, and set pageSize to A4). Again, this was the code:
string outputFileName = "ZoomRaw_1.pdf";
// Original PDF FileStream input = File.Open(testFilePath + "DALA-07-020-20080505-003.pdf", FileMode.Open); //
FileStream output = File.Open(outputFileName , FileMode.Create); // We bind the original PDF to PdfPageEditor object, set the zoom, // and save it to the empty PDF:
PdfPageEditor pdfEditor = new PdfPageEditor();
pdfEditor.BindPdf(input);
// ---------- ALLIGMENT ------------- pdfEditor.Alignment = AlignmentType.Center; // <-------- pdfEditor.VerticalAlignment = Aspose.Pdf.Kit.VerticalAlignmentType.Bottom; // <-------
pdfEditor.Zoom = float.Parse("0,8");
pdfEditor.PageSize = PageSize.A4;
pdfEditor.Save(output);
output.Flush(); output.Close();
input.Flush(); input.Close();
Thanks for your responses :-)
Best Regards.
|
|
-
07-07-2008, 1:26 AM |
-
emilioMalaga
-
-
-
Joined on 02-28-2008
-
Sweden
-
Posts 56
-
-
-
-
|
Re: Zoom of a PDF and subsequent placement at certain position
Dear,
I'd like to ask about the status of this issue, and I also would like to know if the information I provided on my last post has been considered too.
Best regards
|
|
-
07-07-2008, 1:59 AM |
-
Felix.Liu
-
-
-
Joined on 10-10-2007
-
-
Posts 300
-
-
-
-
|
Re: Zoom of a PDF and subsequent placement at certain position
Hi,
Sorry to tell you the issue is still in progress. We need another several days to resovle it, and the information you provided has been taken into account(yes, it's a bug).
Thanks,
Felix Liu Developer Aspose Changsha Team About Us Contact Us
|
|
-
07-18-2008, 2:04 AM |
-
Felix.Liu
-
-
-
Joined on 10-10-2007
-
-
Posts 300
-
-
-
-
|
Re: Zoom of a PDF and subsequent placement at certain position
Attachment: Present (inaccessible)
Hi,
3 issues (PdfKitNet- 5408,5409,5482) have been resolved. Please try the attachment before we publish the new release. And your feedback will be greatly appreciated.
Thanks,
Felix Liu Developer Aspose Changsha Team About Us Contact Us
|
|
-
07-18-2008, 8:36 AM |
-
emilioMalaga
-
-
-
Joined on 02-28-2008
-
Sweden
-
Posts 56
-
-
-
-
|
Re: Zoom of a PDF and subsequent placement at certain position
Hi,
I have replaced the old Aspose.Pdf.Kit.dll file with the one that is attached, but Visual Studio 2005 claims that cannot find the "Aspose" namespace because the reference is missing (even after updating the references both manually and from VStudio, or after deleting/adding them).
Aspose.Pdf.Kit version installed in the PC is 3.1.0.0
It's running .NET 2.0
Any suggestion?
Thanks.
|
|
-
07-19-2008, 12:16 AM |
-
Felix.Liu
-
-
-
Joined on 10-10-2007
-
-
Posts 300
-
-
-
-
|
Re: Zoom of a PDF and subsequent placement at certain position
Hi,
That's quite strange but, after downloading the attachment and checking the dll on my machine, I am sure that the attached dll is the right one. Then, the only thing I could remind you is the version of this Beta dll should be 3.1.0.7, hope this helps.
Thanks,
Felix Liu Developer Aspose Changsha Team About Us Contact Us
|
|
-
07-21-2008, 5:12 AM |
-
emilioMalaga
-
-
-
Joined on 02-28-2008
-
Sweden
-
Posts 56
-
-
-
-
|
Re: Zoom of a PDF and subsequent placement at certain position
Hi,
Unfortunately, I still cannot use that dll.
I've done many different attempts with different Aspose.Pdf.Kit dlls and I think that, in order for Visual Studio to build correctly, the computer must have installed the Aspose.Pdf.Kit software version that corresponds to the new dll (http://www.aspose.com/community/files/51/file-format-components/aspose.pdf.kit/default.aspx).
Could that be the reason?
If that is the case, could you provide the corresponding installer package (.msi)?
Thanks.
|
|
-
07-21-2008, 7:23 AM |
-
Felix.Liu
-
-
-
Joined on 10-10-2007
-
-
Posts 300
-
-
-
-
|
Re: Zoom of a PDF and subsequent placement at certain position
Attachment: Present (inaccessible)
Hi,
Please make sure one old version(eg. 3.1.0.0) of Aspose.Pdf.Kit has been installed on the machine, and you need not replace the old dll with new one.
Please just "remove" the old reference of Aspose.Pdf.Kit and then "add reference" for the new dll( browse and select from its directory), you could do that in the Solution Explorer of VS2005 .
Thanks,
Felix Liu Developer Aspose Changsha Team About Us Contact Us
|
|
-
07-22-2008, 6:35 AM |
-
emilioMalaga
-
-
-
Joined on 02-28-2008
-
Sweden
-
Posts 56
-
-
-
-
|
Re: Zoom of a PDF and subsequent placement at certain position
Hi,
I had tried your suggestions before (thanks a lot anyway :-). After a thorough manual replacement of dll files I could use the attachment, sorry about that.
The zoom/positioning problem is solved for the tests I have made.
Good job!
|
|
Page 1 of 2 (19 items)
1
|
|