You are not logged in.
Thank you for your time and efforts !
I wanted to use SynPdf to get the shading as shown in this picture
.
The Java source code of how to produce this smooth shading effect is on gist.github.com as https://gist.github.com/anonymous/a60cb … panel-java.
How to display smooth shading of a circle with EPS is shown in three steps :
The source file is https://gist.github.com/anonymous/a60cb … ition1-eps
The source file is https://gist.github.com/anonymous/a60cb … ition2-eps
The source file is https://gist.github.com/anonymous/a60cb … ition3-eps
Could you help to comment whether it is possible to use SynPdf to produce the given radial gradient of a circle ?
PS: It seems the forum does not attributes to img tag to resize image ?
Last edited by ComingNine (2014-08-15 21:20:46)
Offline
Some low-level shading PDF commands are missing in the current version of SynPDF.
You may be able to add the shfill() method to TPDFCanvas, which would render as "sh" command.
We would need also to add the TPDFShading kind of object.
I found some reference code in p_shading.c as published in http://www.pdflib.com/download/free-sof … ib-lite-7/
Offline
Thank you for your knowledgeable comments !
Both PDFlib 9 and PDFlib lite 7 provide the shading as shown in the first post. A sample Java program is shown as below:
// http://www.pdflib.com/fileadmin/pdflib/Cookbook/java/color/color_gradient.java
import com.pdflib.pdflib;
import com.pdflib.PDFlibException;
public class color_gradient {
public static void main(String argv[]) {
String outfile = "color_gradient.pdf";
pdflib p = null;
int sh;
try {
p = new pdflib();
// This means we must check return values of load_font() etc.
p.set_option("errorpolicy=return");
if (p.begin_document(outfile, "") == -1)
throw new Exception("Error: " + p.get_errmsg());
p.begin_page_ext(595, 842, "");
// Fill a circle with a gradient: Save the current graphics state
p.save();
// Set the first color for the gradient to white
p.setcolor("fill", "rgb", 1.0, 1.0, 1.0, 0.0);
// Set the second color for the gradient; define a radial gradient
sh = p.shading("radial",
182.32, 617.68,
182.32, 617.68,
0.9412, 0.0, 0.0, 0.0,
"r0 0 r1 50 extend0 false extend1 true");
// Draw a circle and set the clipping path to the shape of the circle
p.circle(200, 600, 50);
p.clip();
// Fill the clipping path with the gradient
p.shfill(sh);
// Restore the current graphics state to reset the clipping path
p.restore();
p.end_page_ext("");
p.end_document("");
}
catch (PDFlibException e) {
System.err.print("PDFlib exception occurred:\n");
System.err.print("[" + e.get_errnum() + "] " + e.get_apiname()
+ ": " + e.get_errmsg() + "\n");
}
catch (Exception e) { System.err.println(e.getMessage()); }
finally { if (p != null) { p.delete(); } }
}
}
However, I knows little about the inside of SynPDF. O_O
Do you think if you could help to put in the abilities ?
Offline
AFAIK we should introduce two things:
1. New TPDFShading kind of object, and its TPDFCanvas.AddShading() wrapper to initialize the shading.
2. New TPDFCanvas.ShadingFill() method, which would render as "sh" command.
Then, we may be able to include those methods from TMetaFile rendering.
TPdfEnum.GradientFill() is already there to implement EMR_GRADIENTFILL, still waiting for shading support at TPDFCanvas level...
Offline
Thank you for your elaboration of what should be done source-code-wise, but I am wondering if you could help to implement the feature ?
Offline
Dear Arnaud, is it possible for you to implement this feature ?
Offline