Free Support Forum - aspose.com

Print on Customer PDF Document

OK, I admit it, I'm new to Aspose. I'm just learning the software and was following a demo to print a circle on PDF and it works. Now, how do I print on a customer pdf document? Where in the code do I specify that?

Thanks

Hi,

Thank you for considering Aspose.

Please refer to PdfViewer. But I am not very clear about your requirement. If you need more help please elaborate your requirement.

Thanks Tommy,

Specifically, what I'm doing is using vb.net to print a circle on a customer mapping document. I used the demo below.

Dim pdf1 as pdf = new pdf()

Dim sec1 as Section=pdf1.Sections.Add()

Dim graph1 as Graph = New Graph(sec1, 100, 400)

sec1.Paragraphs.Add(graph1)

Dim circle1 As Circle=New Circle(graph1, 100, 50, 30)

graph1.Shapes.Add(Circle1)

Circle1.GraphInfo.Color=New Aspose.Pdf.Color=("Red")

pdf1.Save("C:...\customMap.pdf")

**What I want to do is view and print the circle on customMap.pdf. However, the only thing I get is the default Aspose.pdf demo document?

Thanks,

a_pmech2000

Hi,

Do you mean you want to add a circle on the existing PDF file? If so you should use Aspose.Pdf.Kit instead of Aspose.Pdf. Please refer to PdfcontentEditor.CreateSquareCircle.

Tommy, thanks, yes, that's what I need to do. The example I looked at (Circle Constructor on Aspose.pdf) would do everything I needed except print out on the customers PDF file instead of the Aspose.pdf default template. It can be found at:

http://www.aspose.com/documentation/file-format-components/aspose.pdf-for-.net-and-java/aspose.pdf.circle.html

Can I specify a customer document instead of the default temporary template on the circle constructor?

Regards,

a_pmech2000

Hi,

Aspose.Pdf and Aspose.Pdf.Kit are different products. Aspose.Pdf is used to create PDF from scratch and Aspose.Pdf.Kit is used to manipulate existing PDF. So the example of Aspose.Pdf.Circle can't be used for existing PDF.

Thanks Tommy,

I've got the 'kit' now. Utilizing the example code on the site for Creating Square Circle, the line in red is causing an error.

Dim editor As Kit.PdfContentEditor = New Kit.PdfContentEditor()Dim rect As System.Drawing.Rectangle = New System.Drawing.Rectangle(100, 100, 20, 20)
Dim KitTestPath As String = "H:\pdfkit\"
Dim KitTestOut As String = "H:\pdfkit\"
editor.BindPdf(KitTestPath + "example1.pdf")

System.Drawing.Color(clr = Color.FromArgb(255, 255, 0, 10))

editor.CreateSquareCircle(rect, "welcome to aspose", clr, False, 1, 18)
editor.Save(KitTestOut + "example1_application.pdf")

The error in the line above indicates that "Color is a type in 'Drawing" and cannot be used as an expression."

I took the code right off the Aspose website to use as a demo. Can you tell me what I need to do to make the demo run?

Thanks,

a_pmech2000

Hi,

The statement should be (the extra pair of brackets should be removed)

System.Drawing.Color clr=Color.FromArgb(255,255,0,10)

Thanks.

Thanks Adeel but I'm still getting the same error when I use that line. What I did was to declare clr as System.Drawing.Color in the partial class declaration and then used clr=System.Drawing.Color.FromArgb(255,255,0,10). But, now I'm getting an "Object not set to an instance of an object" with this line highlighted.

editor.CreateSquareCircle(rect, "welcome to aspose", clr, False, 10, 40)

This is what my code looks like

Dim rect As System.Drawing.Rectangle = New System.Drawing.Rectangle(100, 100, 20, 20)
Dim KitTestPath As String = "G:\...\"
Dim KitTestOut As String = "G:\...\"
editor.BindPdf(KitTestPath + "customermap.pdf")
clr = System.Drawing.Color.FromArgb(0, 255, 0, 10)
'System.Drawing.Color(clr = Color.FromArgb(255, 255, 0, 10))
editor.CreateSquareCircle(rect, "Customer Welcome", clr, False, 1, 10)
editor.Save(KitTestOut + "custommap.pdf")

I want to print out a square or circle over a part of the pdf and view it before printing. But, as soon as it gets to the line above, it fails. If I comment it out, it prints the file but, of course, no circle or box. Any help you can give me is appreciated. It appears that it'll suit our needs if I can get it to work.

Thanks,

a_pmech2000

Hi,

I used the following code and didn't get any problems.

Dim editor As PdfContentEditor = New PdfContentEditor()

Dim rect As System.Drawing.Rectangle = New System.Drawing.Rectangle(100, 100, 20, 20)

Dim KitTestPath As String = ""

Dim KitTestOut As String = ""

editor.BindPdf(KitTestPath + "example1.pdf")

Dim clr As System.Drawing.Color = System.Drawing.Color.FromArgb(255, 255, 0, 10)

editor.CreateSquareCircle(rect, "welcome to aspose", clr, False, 1, 18)

editor.Save(KitTestOut + "example1_application.pdf")

Thanks.

Thanks Adeel,

This is exactly what I have with the exception of one statement, this one:

Dim clr As System.Drawing.Color=System.Drawing.Color.FromArgb(255, 255, 0, 10)

The statement will not pass VB.NET. So, I had to break the statement up. Once I did that, the following statement:

editor.CreateSquareCircle(rect, "welcome to aspose", clr, False, 1, 18) fails? It's a curious thing and this code comes right off your site. What Namespaces other than Aspose.pdf.kit need to be Imported?

Thanks,

a_pmech2000

System.Drawing namespace needs to be imported.